package com.fp.cyclops.demo;

import com.aol.cyclops.comprehensions.donotation.typed.Do;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;

/**
 * Created by user on 17/9/13.
 */
public class CompletableFutureTest {

    @Test
    public void test1(){
        CompletableFuture<String> f =   CompletableFuture.completedFuture("hello world");
        CompletableFuture<String> f2 = CompletableFuture.completedFuture("2");
        CompletableFuture<String> f3 = CompletableFuture.completedFuture("3");
        CompletableFuture<String> result = Do.add(f)
                .add(f2)
                .add(f3)
                .yield(v1->v2->v3 -> v1 +v2 +v3)
                .unwrap();
    }

    @Test
    public void test2(){
        List<Integer> list= Arrays.asList(1,2,3);
        Do.add(list);
        List<Integer> stream = Do.add(list)
                .yield(i-> i +2).unwrap();
        //assertThat(Arrays.asList(3,4,5),equalTo(stream.collect(Collectors.toList())));
    }
}
